package com.wu.hbase;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@SpringBootTest(classes = HbaseApp.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class HbaseTest {
	@Autowired
	private HbaseService hbaseService;
	
	@Test
	public void createTable() {
		try {
			hbaseService.createTable("stu", "info");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void putData() {
		String name = "stu";
		String colFamily = "info";
		String rowKey = "2";
		Map<String, String> data = new HashMap<>();
		data.put("name", "bbb");
		data.put("email", "bb@126.com");
		try {
			hbaseService.putData(name, colFamily, rowKey, data);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void getData() {
		try {
			hbaseService.getData("stu");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}